package com.kun.spring.bean;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

/**
 * @Classname HelloFactory
 * @Created by FangKun
 * @Date 2022/11/19 0019 上午 9:37
 */

/**
 * 普通Bean，比如Person，注册的对象就是Person对象，类型就是Person
 *
 * 工厂Bean，实现了FactoryBean接口的组件，注册的不是HelloFactory，
 * 而是getObject()返回的对象，类型为getObjectType()
 * 例如Mybatis和Spring整合的sqlsessionFactoryBean
 */
@Component
public class HelloFactory implements FactoryBean<Hello> {
	@Override
	public Hello getObject() throws Exception {
		return new Hello();
	}

	@Override
	public Class<?> getObjectType() {
		return Hello.class;
	}
}
